package com.qingyi.mall.coupon.controller;

import java.util.Arrays;
import java.util.Map;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.qingyi.mall.coupon.entity.PmsBrandEntity;
import com.qingyi.mall.coupon.service.PmsBrandService;
import com.qingyi.mall.common.utils.PageUtils;
import com.qingyi.mall.common.utils.R;



/**
 * 品牌
 *
 * @author qingyi
 * @email qingyi@gmail.com
 * @date 2020-07-12 19:59:59
 */
@RestController
@RequestMapping("coupon/pmsbrand")
@Api(tags = "品牌")
public class PmsBrandController {
    @Autowired
    private PmsBrandService pmsBrandService;

    /**
     * 列表
     */
    @RequestMapping(value = "/list",method = RequestMethod.GET)
    @ApiOperation(value = "获取列表",notes = "获取品牌的列表")
    //@RequiresPermissions("coupon:pmsbrand:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = pmsBrandService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping(value = "/info/{brandId}",method = RequestMethod.GET)
    @ApiOperation(value = "信息",notes = "获取品牌的信息")
    //@RequiresPermissions("coupon:pmsbrand:info")
    public R info(@PathVariable("brandId") Long brandId){
		PmsBrandEntity pmsBrand = pmsBrandService.getById(brandId);

        return R.ok().put("pmsBrand", pmsBrand);
    }

    /**
     * 保存
     */
    @RequestMapping(value = "/save",method = RequestMethod.POST)
    @ApiOperation(value = "保存",notes = "保存品牌的信息")
    //@RequiresPermissions("coupon:pmsbrand:save")
    public R save(@RequestBody PmsBrandEntity pmsBrand){
		pmsBrandService.save(pmsBrand);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping(value = "/update",method = RequestMethod.PUT)
    @ApiOperation(value = "修改",notes = "修改品牌的信息")
    //@RequiresPermissions("coupon:pmsbrand:update")
    public R update(@RequestBody PmsBrandEntity pmsBrand){
		pmsBrandService.updateById(pmsBrand);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping(value = "/delete",method = RequestMethod.DELETE)
    @ApiOperation(value = "修改",notes = "修改品牌的信息")
    //@RequiresPermissions("coupon:pmsbrand:delete")
    public R delete(@RequestBody Long[] brandIds){
		pmsBrandService.removeByIds(Arrays.asList(brandIds));

        return R.ok();
    }

}
